<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="yes" name="apple-touch-fullscreen">
	<meta content="telephone=no,email=no" name="format-detection">
	<!--防止css、js资源缓存-->
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<script type="text/javascript" src="asserts/resource/js/flexible_C.js" ></script>
	<link rel="stylesheet" href="asserts/resource/css/common.css">
	<link rel="stylesheet" href="asserts/resource/css/css.css">
	<title>首页</title>

</head>
<body id="index-bg">
<div class="index-bg">
	<div class="index-content">
		<div class="index-status">
			<h1 id="terminalType"></h1>
			<p><span>静止</span><span>电量:<a>30%</a></span></p>
		</div>
		<div class="sos-phone">
            <div class="belltime"><span id="sosbell"><i class="sosbell"></i></span><span class="current-time"><a id="setTime">正在查询报警信息...</a></span></div>
            <div id="warninfobox"><div id="warninfo"></div><div id="warninfo2"></div></div>
		</div>
		<div class="item-url-button">
			<ul>
				<li><span><a href="javascript:void(0);" class="url-RealTimeLocation" onclick="window.location.href='RealTimeLocation.html'" target="_blank" ><i>实时定位</i></a></span></li>
				<li><span><a href="javascript:void(0);" class="url-HistoricalRoute" onclick="window.location.href='HistoricalRoute.html'" target="_blank"><i>历史轨迹</i></a></span></li>
			</ul>
			<ul>
				<li><span><a href="javascript:void(0);" class="url-AreaEdit" onclick="window.location.href='AreaEdit.html'" target="_blank"><i>区域编制</i></a></span></li>
				<li><span><a href="javascript:void(0);" class="url-Setting" onclick="window.location.href='Setting.html'"><i>设置</i></a></span></li>
			</ul>
			<ul>
				<li><span><a href="javascript:void(0);" class="url-EquipmentInfomation" onclick="window.location.href='EquipInfo.html'"><i>设备消息</i></a></span></li>
				<li><span><a href="javascript:void(0);" class="url-Logout" id="logout"><i>注销登录</i></a></span></li>
			</ul>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="asserts/resource/js/jquery.min.js"></script>
<script type="text/javascript" src="asserts/resource/layer/mobile/layer.js"></script>
<script type="text/javascript" src="asserts/resource/js/js.js"></script>
<script type="text/javascript" src="asserts/resource/js/index/index.js"></script>
<script>
</script>
<script>

    var scrollbox = document.getElementById("warninfobox");
    var scrollA = document.getElementById("warninfo");
    var scrollB = document.getElementById("warninfo2");

    function MarqueeLeft(){

        if(scrollB.offsetWidth - scrollbox.scrollLeft <= 0) {

            scrollbox.scrollLeft -= scrollA.offsetWidth
        }else {

            scrollbox.scrollLeft++;


        }
    }
    setInterval(MarqueeLeft, 60);




    var curIndex = 0;
    var arr=null;
    var tt=null;

    window.onload = function(){//页面加载时
        getAlert();//查询缓存报警信息
        setInterval("getAlert()",10000);//定时调用查询告警接口
        tt=window.setInterval("changeAlert();",1000);//设置每秒改变
        //setTimeout("cleanInterval()",20000);//定时40秒后取消报警
    }
    //查询告警信息
    function getAlert(){
        $.ajax({
            type: "POST",
            url: "alert/warning",
            dataType: "json",
            success: function(result){
                console.log(result)
                arr=result.data;
            }
        });
    }
    //改变告警信息
    function changeAlert() {
        var obj = document.getElementById("warninfo");
        var timeObj = document.getElementById("setTime");
        if (curIndex == arr.length-1) {
            curIndex = 0;
        } else {
            curIndex += 1;
        }
        obj.innerHTML = arr[curIndex].alertName;
        timeObj.innerHTML=arr[curIndex].alertTime;
    }

    //去掉定时器的方法
    function cleanInterval() {
        setTimeout("clearInterval(tt)",20000);
    }
</script>
</html>
